/**  
 
* @author xuzhixiang 

* @date 2018年10月7日  

*/  
package com.moxi.study.hadoop.mapReduce;

import java.io.IOException;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

/**
 * Reduce测试过程
 * @author xuzhixiang
 * @date 2018年10月7日下午7:31:47  
 */
public class TestReduce extends Reducer<Text, IntWritable, Text, IntWritable>{

	/**
	 * Reduce 统计单词出现的次数
	 */
	@Override
	protected void reduce(Text arg0, Iterable<IntWritable> arg1, Context arg2) throws IOException, InterruptedException {
		int count = 0;
		for (IntWritable iw : arg1) {
			count = count + iw.get();
		}
		arg2.write(arg0, new IntWritable(count)); 
	}
	
	
}
